from collections.abc import Iterable,Iterator
class Company(object):
    def __init__(self,empolyee_list):
        self.employee_list=empolyee_list

    def __iter__(self):#返回对象的引用
        return MyIterator(self.employee_list)

    def __getitem__(self, item):
        return self.employee_list[item]

class MyIterator(Iterator):
    def __init__(self,employee_list):
        self.iter_list=employee_list
        self.index=0
    def __next__(self):
        try:
            word=self.iter_list[self.index]

        except IndexError:
            raise StopIteration
        self.index += 1
        return word
if __name__ == '__main__':
    company=Company(['AK','AKW','AKM'])

    print(isinstance(company,Iterable))
    for i in company:
        print(i)
    my_iter=iter(company)
    print(isinstance(MyIterator,Iterator))
    while True:
        try:
            print(next(my_iter))
        except StopIteration:
            pass
